home *** CD-ROM | disk | FTP | other *** search
/ Audio 4.94 - Over 11,000 Files / audio-11000.iso / mac / soundutl / rvrb52cp.hqx / Reverb v5.2 folder / Reverb programs / TwoPoleLPF < prev    next >
Encoding:
Text File  |  1993-10-06  |  1.3 KB  |  41 lines

  1. //
  2. // Two pole, two zero, resonant lowpass filter.
  3. // Both zeros are at the Nyquist frequency, and the
  4. // conjugate pole pair can be moved around by selecting
  5. // the angular frequency (w) and radius (r) of the
  6. // poles. The filter is normalized at DC.
  7. //
  8. // All in all, this is a bad implementation, suffering
  9. // from a variety of ills. Since coefficients can't be
  10. // greater than +/- 1.0, the biquad implementation
  11. // uses multiple FIR taps to get coefficients greater
  12. // than 1, and is thus really inefficient. Headroom
  13. // scaling is similarly awkward. Finally, the control
  14. // using (r,w) is bad since r doesn't have good
  15. // resolution near 1, and specifying fc and Q would
  16. // be better. But, it works and is instructional.
  17. //
  18. // MIDI ctl 1 -> roughly fc from 32 to 8kHz in log freq
  19. // MIDI ctl 2 -> radius of poles from 0 to 1 (!)
  20. //
  21. // Bill Gardner, March, 1993
  22. //
  23. #include "macros.rvb"
  24. #include    "biquad.rvb"
  25.  
  26. #define PI 3.1415923
  27. #define w    (32 * pow(2,range(ctl(1),0,8)) * 2 * PI / fs)
  28. #define r    init(115/127,ctl(2))
  29. #define hdrm    16        // 24 dB of headroom
  30.  
  31. // get monophonic input
  32. fir(0, Lin, 0.5 / hdrm, Rin, 0.5 / hdrm);
  33. // DC normalized two pole lowpass
  34. biquad(0, Lout, (1 - 2*r*cos(w) + r*r) / 4,
  35.     2*r*cos(w), -r*r, 1, 1, 2);
  36. // scale output by 8 (18 dB)
  37. add(Lout,Lout);
  38. add(Lout,Lout);
  39. add(Lout,Lout);
  40. move(Lout,Rout);
  41.